from django.db import models


class CourseGroup(models.Model):
    """分组"""
    group_name = models.CharField('分类名', max_length=64, unique=True)
    create_time = models.DateTimeField("创建时间", auto_now_add=True)
    update_time = models.DateTimeField("修改时间", auto_now=True)
    is_delete = models.BooleanField('是否删除', default=False)

    class Meta:
        db_table = 'course_group'


class Course(models.Model):
    """课程"""
    course_group = models.ForeignKey(CourseGroup, on_delete=models.DO_NOTHING)
    c_course_name = models.CharField('课程中文名', max_length=128, unique=True)
    e_course_name = models.CharField('课程英文名', max_length=128, unique=True)
    create_time = models.DateTimeField("创建时间", auto_now_add=True)
    update_time = models.DateTimeField("修改时间", auto_now=True)
    is_delete = models.BooleanField('是否删除', default=False)

    class Meta:
        db_table = 'course'


class RotationMap(models.Model):
    """轮播图"""
    img = models.CharField('图片链接', max_length=128)
    order = models.IntegerField(verbose_name='排序', db_column='sort', default=0, blank=True, null=True)
    create_time = models.DateTimeField("创建时间", auto_now_add=True)
    update_time = models.DateTimeField("修改时间", auto_now=True)
    is_delete = models.BooleanField('是否删除', default=False)

    class Meta:
        db_table = 'rotation_map'
        ordering = ['order', '-create_time']


class PdfManage(models.Model):
    """pdf管理"""
    pdf_path = models.CharField('pdf文件路径', max_length=128)
    pdf_name = models.CharField('pdf文件名称', max_length=256)
    course_schedule = models.CharField('课程表', max_length=64)
    course_score = models.CharField('课程学分', max_length=64, default="0")
    school_name = models.CharField('学校名称', max_length=64)
    is_delete = models.BooleanField('是否删除', default=False)
    create_time = models.DateTimeField("创建时间", auto_now_add=True)
    update_time = models.DateTimeField("修改时间", auto_now=True)

    class Meta:
        db_table = 'pdf_manage'
        ordering = ['pdf_name', '-create_time']
